﻿Public Class m_empresas
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        seguridad.verificapermisos()
    End Sub

    Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click

        ASPxGridViewExporter1.WritePdfToResponse()
    End Sub

    Protected Sub ImageButton2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton2.Click
        ASPxGridViewExporter1.WriteXlsxToResponse()
    End Sub

    Protected Sub ASPxButton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ASPxButton1.Click
        Dim query As String = String.Format("insert into empresas (nombreempresa, gerentegeneral , telefonoempresa,email,sitioweb ,observacion,direccion) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", txtempresa.Text, txtgerente.Text, txttelefono.Text, txtemail.Text, txtsitioweb.Text, txtobservacion.Text, txtobservacion.Text)
        Try
            Dim con As New Devart.Data.PostgreSql.PgSqlConnection(seguridad.conexion)
            con.Open()
            Dim ejec As New Devart.Data.PostgreSql.PgSqlCommand(query, con)
            ejec.ExecuteNonQuery()
            con.Close()
        Catch ex As Exception
            MsgBox("No se pudo insertar a la base de datos")
        End Try

        
        txtempresa.Text = ""
        txtgerente.Text = ""
        txttelefono.Text = ""
        txtemail.Text = ""
        txtsitioweb.Text = ""
        txtobservacion.Text = ""
        txtobservacion.Text = ""
        ASPxGridView1.DataBind()

    End Sub

    Protected Sub ImageButton3_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton3.Click
        Dim sUrl As String = "frmempresas.aspx"
        Dim sScript As String = "<script language =javascript> "
        sScript += "window.open('" & sUrl & "',null,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=300,left=100,top=100');"
        sScript += "</script> "
        Response.Write(sScript)
        Dim repot As New rptEmpresas
        repot.EmpresasTableAdapter.Fill(repot.DataSet11.empresas)
    End Sub
End Class